package com.swotxu.common.utils;

import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * @Date: 2021/1/9 19:26
 * @Author: swotXu
 */
public abstract class ComparableUtil {

    public static int comparedWithZeroOfBigDecimal(@NotNull BigDecimal num) {
        return BigDecimal.ZERO.compareTo(num);
    }
    public static boolean gtZeroOfBigDecimal(String num) {
        if (StringUtils.isBlank(num)) {
            return false;
        }
        try {
            return comparedWithZeroOfBigDecimal(new BigDecimal(num)) == -1;
        } catch (Exception exception) {
            return false;
        }
    }
    public static boolean gtZeroOfBigDecimal(@NotNull BigDecimal num) {
        return comparedWithZeroOfBigDecimal(num) == -1;
    }

    public static boolean gtZeroOfLong(String num) {
        return StringUtils.isNumeric(num) && Long.parseLong(num) > 0;
    }

    public static boolean gtZeroOfInteger(String num) {
        return StringUtils.isNumeric(num) && Integer.parseInt(num) > 0;
    }
}
